﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Entity;
namespace DataAccess
{
    public class StudentDA
    {
        //load list Student for user account login
        SqlDataAdapter da;
        public DataSet getListStudentByAccount(Account acc)
        {
            using (SqlConnection conn = Connect.getConnection())
            {
                try
                {
                    conn.Open();

                    DataSet ds = null;
                    da = new SqlDataAdapter("getStudentByUserAccount", conn);
                    da.SelectCommand.CommandType = CommandType.StoredProcedure;
                    da.SelectCommand.Parameters.Add(new SqlParameter("@userID", acc.accountID));
                    ds = new DataSet();
                    da.Fill(ds);

                    conn.Close();
                    return ds;
                }
                catch (Exception)
                {
                    conn.Close();
                    return null;
                }
            }
        }
    }
}
